package deliciouse.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import deliciouse.biz.NewsBiz;
import deliciouse.biz.impl.NewsBizImpl;
import deliciouse.entity.News;

@WebServlet("/juggaddnews")
public class NewsManegementUpdateOrAddServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		int id = 0;
		if(request.getParameter("id")!=null && !request.getParameter("id").isEmpty())
			id= Integer.valueOf(request.getParameter("id"));
		NewsBiz newsbiz = new NewsBizImpl();
		News news = newsbiz.fetchById(id);
		request.setAttribute("id", id);
		request.setAttribute("news", news);
		request.getRequestDispatcher("/admin/newsupdate.jsp").forward(request, response);
	}
}
